package com.example.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: 万秋泊
 * @Date: 2021/10/10 16:20
 * @Description:web配置
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    /**
     * 拦截器配置
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/api/**")
                //放行路径，可以添加多个，放心用户和商家的登录注册
                .excludePathPatterns("/api/userLogin")
                .excludePathPatterns("/api/UserRegister")
                .excludePathPatterns("/api/merchantLogin")
                .excludePathPatterns("/api/merchantRegister");
                /*.excludePathPatterns("/api/*");*/

    }

}
